const tool = {}

/**
 * totals提示
 */
tool.msg = (title, duration = 1500, mask = false, icon = 'none') => {
	if(Boolean(title) === false){
		return;
	}
	uni.showToast({
		title,
		duration,
		mask,
		icon
	});
}

/**
 * 判断是否登录, 如果token不存在则直接跳转到登录界面
 */
tool.login = () => {
	if (uni.getStorageSync('token') != undefined && uni.getStorageSync('token') != '') {
		return true
	}
	uni.navigateTo({
		url:'/pages/login/index'
	})
	return false
}

/**
 * 获取前一页
 */
tool.prepage = () => {
	let pages = getCurrentPages();
	let prepage = pages[pages.length - 2];
	// #ifdef H5
	return prepage;
	// #endif
	return prepage.$vm;
}

export default tool